package main

import (
	"fmt"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"gorm.io/gorm/schema"

	"gitee.com/jnshao/go-start/gorm/model"
)

func main() {
	connArgs := fmt.Sprintf("root:123456@(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local")
	db, err := gorm.Open(
		mysql.Open(connArgs),
		&gorm.Config{
			NamingStrategy: schema.NamingStrategy{
				SingularTable: true,
			},
		},
	)
	if err != nil {
		panic(err)
	}
	// 自动迁移
	db.AutoMigrate(&model.User{})

}
